package com.example.love_margin.Mapper;

import com.example.love_margin.Entity.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserMapper {

    @Insert("INSERT INTO user(user_name,user_message,user_state,user_picture)values(#{user_name},#{user_message},#{user_state},#{user_picture})")
    @Options(useGeneratedKeys = true,keyProperty = "user_id")
    int addUserMessage(User user);

    @Delete("DELETE FROM user WHERE user_id=#{user_id}")
    int deleteUserMessage(@Param("user_id") int user_id);


    @Select("SELECT * FROM user WHERE user_state = #{user_state}")
    User selectUserMessageByName(User user);


    @Delete("DELETE FROM user WHERE user_id=#{user_id}")
    int deleteUser(@Param("user_id") int user_id);


    //id查询用户信息
    @Update("UPDATE user SET user_picture=#{user_picture} WHERE user_state = #{user_state}")
    void UpdateUser(@Param("user_picture") String user_picture,@Param("user_state") String user_state);

    //更新用户头像
    @Update("SELECT * FROM user WHERE user_id = #{user_id}")
    User selectOneUser(@Param("user_id") int user_id);


    //查询用户列表
    @Select("SELECT * FROM user")
    List<User> selectUserList();



}
